package com.vpx.server.controller.system;

import cn.hutool.json.JSONObject;
import com.vpx.server.bean.order.base.BaseDelOrder;
import com.vpx.server.bean.order.base.BaseIdStrOrder;
import com.vpx.server.bean.order.system.BaseInfoOrder;
import com.vpx.server.bean.order.system.BaseInfoPageOrder;
import com.vpx.server.bean.order.system.TemplateOrder;
import com.vpx.server.bean.order.system.TemplatePageOrder;
import com.vpx.server.bean.result.system.BaseInfoResult;
import com.vpx.server.bean.result.system.TemplateDetailListResult;
import com.vpx.server.bean.result.system.TemplatePageResult;
import com.vpx.server.bean.result.system.TemplateResult;
import com.vpx.server.framework.authority.AuthPoicy;
import com.vpx.server.framework.authority.RequestAuth;
import com.vpx.server.framework.base.BasePageResult;
import com.vpx.server.framework.base.ResultMsg;
import com.vpx.server.service.system.BaseInfoService;
import com.vpx.server.service.system.SqlExtService;
import com.vpx.server.service.system.TemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 基础用例表、分支表、流程项表管理
 */
@RestController
@RequestMapping(value = "/api/baseInfo")
@Api(tags = "基础用例表、分支表、流程项表管理")
public class BaseInfoController {

    @Autowired
    private BaseInfoService baseInfoService;

    @PostMapping("/insertBaseInfo")
    @ApiOperation("新增")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg insert(@Validated @RequestBody BaseInfoOrder order) {
        return baseInfoService.saveBaseInfo(order);
    }

    @PostMapping("/batchInsertBaseInfo")
    @ApiOperation("批量新增")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg batchInsertBaseInfo(@Validated @RequestBody List<BaseInfoOrder> order) {
        return baseInfoService.batchSaveBaseInfo(order);
    }

    @DeleteMapping("/deleteBaseInfo")
    @ApiOperation("删除")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg deleteBaseInfo(@Validated @RequestBody BaseDelOrder order) {
        return baseInfoService.deleteBaseInfo(order);
    }

    @PostMapping("/updateBaseInfo")
    @ApiOperation("修改")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg updateById(@RequestBody BaseInfoOrder order) {
        return baseInfoService.updateBaseInfoById(order);
    }

    @GetMapping("/selectBaseInfoById")
    @ApiOperation("查询详情")
    @RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<BaseInfoResult> selectById(BaseIdStrOrder order) {
        return baseInfoService.selectBaseInfoById(order);
    }

    @GetMapping("/pageQueryBaseInfo")
    @ApiOperation("分页查询")
    //@RequestAuth(poicy = AuthPoicy.AUTH)
    public ResultMsg<BasePageResult<BaseInfoResult>> pageQueryBaseInfo(BaseInfoPageOrder order) {

        return baseInfoService.pageQueryBaseInfo(order);
    }


}
